﻿namespace UnitTest.Dxp.Core3

open System
open Microsoft.VisualStudio.TestTools.UnitTesting
open Lib.Dxp.Core

[<TestClass>]
type UnitTest_DxpCore() = 
    
    [<TestMethod>]
    member x.isSome () = 
        Assert.AreEqual(false, isSome null)
        Assert.AreEqual(false, isSome DBNull.Value)
        Assert.AreEqual(false, isSome "")
        Assert.AreEqual(true, isSome "1")

    [<TestMethod>]
    member x.isNone () = 
        Assert.AreEqual(true, isNone null)
        Assert.AreEqual(true, isNone DBNull.Value)
        Assert.AreEqual(true, isNone "")
        Assert.AreEqual(false, isNone "1")

    [<TestMethod>]
    member x.Nullabler () = 
        let x : Nullable<int> = Nullable<int>()
        Assert.AreEqual(true, isNone x)
        Assert.AreEqual(false, isSome x)
        let x : Nullable<int> = Nullable<int>(8)
        Assert.AreEqual(false, isNone x)
        Assert.AreEqual(true, isSome x)


    [<TestMethod>]
    member x.DbNullabler () = 
        let x = System.Data.SqlTypes.SqlInt32(8)
        Assert.AreEqual(false, isNone x)
        Assert.AreEqual(true, isSome x)
        let x = System.Data.SqlTypes.SqlInt32()
        Assert.AreEqual(true, isNone x)
        Assert.AreEqual(false, isSome x)
  
    [<TestMethod>]
    member x.DbX () = 
        let x = System.Data.SqlTypes.SqlInt32(8)
        Assert.AreEqual("8", string x)
  
    [<TestMethod>]
    member x.DbXn () = 
        Assert.AreEqual("1.56", to_s 1.56)
        Assert.AreEqual("1.56", to_s 1.56m)
        Assert.AreEqual("1980-12-21 00:00:00", to_s (System.DateTime(1980, 12, 21)))
        Assert.AreEqual("1980-12-21 23:40:45", to_s (System.DateTime(1980, 12, 21, 23, 40, 45)))
  
  
